package com.lsh.utils;

import com.lsh.pojo.User;
import org.springframework.stereotype.Component;

/**
 * 通过ThreadLocal来存储用户信息，进行会话管理，代替session的使用
 */

@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }

    public void clear() {
        users.remove();
    }

}
